{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "fa9ffb09-e121-4dc3-b4ce-2f49ffc79b8e",
   "metadata": {},
   "source": [
    "# Horizontal Bar Chart with Labels\n",
    "\n",
    "A horizontal bar chart for comparing category values along the y-axis. This example uses the `penguins` dataset to show average body mass per species. Labels are added as an overlay."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bf923874-3780-46e6-b71a-c66cd6edd12e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas  # noqa\n",
    "\n",
    "df = hvplot.sampledata.penguins('pandas')\n",
    "grouped = df.groupby('species', observed=True)['body_mass_g'].mean()\n",
    "\n",
    "grouped.hvplot.barh(\n",
    "    x='species',\n",
    "    y='body_mass_g',\n",
    "    xlabel='Species',\n",
    "    ylabel='Body Mass (g)',\n",
    "    legend=False,\n",
    "    title='Horizontal Bar Chart (Bokeh)',\n",
    "    width=400, height=400,\n",
    ") * grouped.hvplot.labels(\n",
    "    x='species',\n",
    "    y='body_mass_g',\n",
    "    hover=False,\n",
    "    text=\"{body_mass_g:.0f} g \",\n",
    "    text_color='white',\n",
    "    text_align=\"right\",\n",
    "    width=400, height=400,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6335a800-d505-4fb6-a235-35c2acb62d9c",
   "metadata": {},
   "source": [
    ":::{seealso}\n",
    "- [Horizontal Bar Plots reference documentation](../../ref/api/manual/hvplot.hvPlot.barh.ipynb).\n",
    "- [Labels reference documentation](../../ref/api/manual/hvplot.hvPlot.labels.ipynb).\n",
    ":::"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
